/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import java.util.Calendar;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Felipe
 */
@Entity
@Table (name = "SESIONES")
@NamedQueries
({
    @NamedQuery (name = "sesionPorCodigo", query = "select s from Sesion s where s.codigo = ?1")
})
public class Sesion implements Serializable
{
    @Id
    @Column (name = "ID_SESION")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    
    @JoinColumn (name = "USUARIO")
    @ManyToOne (cascade = CascadeType.REFRESH)
    private Usuario usuario;

    @Column (name = "INICIO")
    @Temporal (TemporalType.TIMESTAMP)
    private Calendar inicio;
    
    @Column (name = "CIERRE")
    @Temporal (TemporalType.TIMESTAMP)
    private Calendar cierre;
    
    @Column (name = "CODIGO")
    private String codigo;
    
    public long getId()
    {
        return id;
    }

    public void setId(long id)
    {
        this.id = id;
    }

    public Usuario getUsuario()
    {
        return usuario;
    }

    public void setUsuario(Usuario usuario)
    {
        this.usuario = usuario;
    }

    public Calendar getInicio()
    {
        return inicio;
    }

    public void setInicio(Calendar inicio)
    {
        this.inicio = inicio;
    }

    public Calendar getCierre()
    {
        return cierre;
    }

    public void setCierre(Calendar cierre)
    {
        this.cierre = cierre;
    }

    public String getCodigo()
    {
        return codigo;
    }

    public void setCodigo(String codigo)
    {
        this.codigo = codigo;
    }

    @Override
    public String toString()
    {
        return "entidades.Sesion[ id=" + id + " ]";
    }
}
